<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div id="content" style="position: relative;width: 1000px;height: 600px;margin: 0 auto">

</div>
<script>

    let content = document.getElementById("content");

    let radius = 300;

    //在content中随机坐标点
    let randomPoint1 = function (content) {
        let x = Math.floor(Math.random() * radius * 2) - radius;
        let y = Math.floor(Math.random() * radius * 2) - radius;
        return x * x + y * y <= radius * radius ? {x: 500 + x, y: 500 + y} : randomPoint1(content);
    };

    let randomPoint2 = function (content) {
        const u = Math.random();
        const theta = Math.random() * 2 * Math.PI;
        const r = Math.sqrt(u);
        return {x: 500 + r * Math.cos(theta) * radius, y: 500 + r * Math.sin(theta) * radius};
    };

    let createPoint = function (content, x, y) {
        return `<div style='width: 5px;height: 5px;background-color: black;position: absolute;left:${x}px;top: ${y}px'></div>`
    };

    for (let i = 0; i < 1500; i++) {
        let random = randomPoint2(content);
        content.innerHTML += createPoint(content, random.x, random.y);
    }


</script>
</body>
</html>
